<template>
  <div>
    <div >
        <div v-for="(item,index) in arr" :key="index"
        style="display: inline-block">

            <input type="checkbox" 
            v-model="newArr"
            :value="item">
            <span>{{item}}</span>
        </div>
        
    </div>
    <p>你选中的元素,累加值为:{{isAll}}</p>
  </div>
</template>

<script>
//遍历数组，添加点击按钮
//把点击的选项，放到一个新的数组里，
//算新数组的和
export default {
data () {
    return {
        arr:[9, 15, 19, 25, 29, 31, 48, 57, 62, 79, 87],
        newArr:[]
    }
},
computed:{
    isAll(){
        return this.newArr.reduce((sum,item)=>{
            return  sum += item
        },0)
    } 
}
}
</script>

<style>

</style>

